package net.googlecode.morenko.task3;

/**
 * Class which calculates salary.
 */
public class SalaryCalculator {
    /**
     * Calculates person salary depends on person status.
     * @param person person whose salary will be calculated.
     */
    public void calc(Object person) {
        long salary;
        if (person instanceof Manager) {
            Manager m = (Manager)person;
            salary = (m.getPerHour()) ? (170 * m.getRate() - m.getTax()) : (m.getRate() - m.getTax());
            if (m.getBonus()) {
                salary += m.getBonusAmT();
            }
            System.out.println("Manager >> " + m.getName() + ", age " + m.getAge() + ", salary: $" + salary);
        }
        else if (person instanceof Employee) {
            Employee e = (Employee)person;
            salary = (e.getPerHour()) ? (170 * e.getRate() - e.getTax()) : (e.getRate() * e.getExperience() - e.getTax());
            if (e.getBonus()) {
                salary += e.getBonusAmT();
            }
            System.out.println("Employee >> " + e.getName() + ", age " + e.getAge() + ", salary: $" + salary);
        }
        else {
            Director d = (Director)person;
            salary = 170 * d.getRate() - d.getTax() + d.getBonusAmT();
            System.out.println("Director >> " + d.getName() + ", age " + d.getAge() + ", salary: $" + salary);
        }
    }
}
